#ifndef WIDGET_H
#define WIDGET_H

#include <QWidget>
#include "modbus.h"
#include <QMap>
namespace Ui {
class Widget;
}

class Widget : public QWidget
{
    Q_OBJECT

public:
    explicit Widget(QWidget *parent = 0);
    ~Widget();
    bool isConnect() const;
    void readRequest(int RegisterType, int regAdress, int size, QVector<quint16> *values);
    void writeRequest(int RegisterType, int regAdress, QVector<quint16>values);
private:
    virtual void timerEvent(QTimerEvent *event);
    QString showCurTime();
private slots:
    void on_btnSend_clicked();
    void on_btnRead_clicked();
    void on_btnConnect_clicked();

    void doProCoils(bool);
signals:
    void coilsValue(int, QVector<quint16>);//待用
private:
    Ui::Widget *ui;
    Modbus *mb;
    QString portName;    // 串口名
    int baudRate;        // 波特率
    int slaveAdress;     //设备地址
    int regAdress;       //线圈地址
    int value;           //值
    int ModBusType;      //类型
    bool m_sigleCoisValue;
    QMap <int, bool> m_coisValue;
};

#endif // WIDGET_H
